package com.bjsxt.userscenter.springmvc.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.bjsxt.userscenter.common.util.ConstatFinalUtil;
import com.bjsxt.userscenter.users.pojo.AAdmins;

@Component
public class AuthInterceptor extends HandlerInterceptorAdapter
{

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
	{
		String info="";
		HttpSession session=request.getSession();
		AAdmins admins=(AAdmins) session.getAttribute("admins");
		if(admins==null){
			info=ConstatFinalUtil.INFO_JSON.getString("7");
			session.setAttribute("info", info);
			response.sendRedirect(request.getContextPath()+"/login.htm");
			return false;
		}else{
			return true;
		}
	}
	
}
